package com.hl.util;

import lombok.Data;

/**
 * @author Hr
 * @date 2024/8/30 16:54
 * R Result
 *
 */
@Data
public class R {
    //操作结果码：请求处理的结果码
    private int code;
    //操作结果描述
    private String msg;
    //前端页面要渲染的数据
    private Object data;

    //操作成功
    public static R success(Object flag){
        R r = new R();
        r.code=200;
        r.msg="操作成功";
        r.setData(flag);
        return r;
    }

    //操作失败
    public static R fail(Object flag){
        R r = new R();
        r.code=500;
        r.msg="操作失败";
        r.setData(flag);

        return r;
    }


    public static R exp(Object data){
        R r = new R();
        r.code=600;
        r.msg="系统异常";
        r.setData(data);

        return r;
    }
}
